﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufScenario.h"
#include "OwnerPtr.h"
#include "GnufImpl.h"

namespace gnuf {
    // ScenarioManager is using a stack to manage those scenarios.
    namespace impl
    {
        class GNUF_IMPL_CLASS(ScenarioManager);
    }

    class GNUF_BASE_EXPORT ScenarioManager final
    {
        GNUF_IMPL_USE(ScenarioManager);
        CANNOT_COPY_OR_ASSIGN(ScenarioManager)
    public:
        ScenarioManager();
        ~ScenarioManager();
        
        static ScenarioManager * get();

        void setCurrentScenarioGroupId(int groupId);

        // Return true, if no any scenario. Otherwise, return false. Normally
        // no possible to return false, since there must be a default one in
        // the stack, at least.
        bool isEmpty() const;
        
        // Return the number of the scenarios.
        size_t numberOfScenarios() const;

        // Return true if it was in the embedded mode. Otherwise, return false.
        bool wasInEmbeddedMode() const;

        // Return the default scenario.
        const Scenario * defaultScenario() const;
        Scenario * defaultScenario();
        
        // Returnt the current scenario.
        const Scenario * currentScenario() const;
        Scenario * currentScenario();

        // Push an new scenario to the stack and 
        // return the current scenario.
        Scenario * pushScenario(Scenario::EType);
        
        // Pop the top scenario from the stack and 
        // return true/false if successful/failed.
        bool popScenario();
        
        // Refresh the scenario, and then return the refreshed scenario.
        const Scenario * refreshScenario();
    };
}

